﻿using Jurassic.Library;

namespace Kiwi.Node.Modules.Builtin
{
    public class EventEmitter : BuiltinModuleObject
    {
        protected EventEmitter(IApplication application) : base(application,(application.Resolve("events") as ObjectInstance).GetPropertyValue("EventEmitter") as FunctionInstance) //base(GetEventEmitterPrototype(application))
        {
        }

        public void InternalAddListener(string @event, object listener)
        {
            CallMemberFunction("on", Engine.String.Construct(@event), listener);
        }

        protected void InternalEmit(params object[] arguments)
        {
            CallMemberFunction("emit", arguments);
        }
    }
}
